package com.rayboo.example.design.pattern.singleton;

public class ConfigsManager {

    private String mFontSize;

    private String mChatBackground;

    private static ConfigsManager sConfigsManagers;

    private ConfigsManager() {
        System.out.println("初始化：从数据库中读取所有设置项");

        // 假设当前数据库文字大小为「中」，聊天背景为「风景」
        mFontSize = "中";
        mChatBackground = "风景";
    }

    public static ConfigsManager getInstance() {
        if (sConfigsManagers == null) {
            synchronized (ConfigsManager.class) {
                if (sConfigsManagers == null) {
                    sConfigsManagers = new ConfigsManager();
                }
            }
        }
        return sConfigsManagers;
    }

    public String getFontSize() {
        return mFontSize;
    }

    public void setFontSize(String fontSize) {
        mFontSize = fontSize;
        System.out.println("将数据库中文字大小设置为" + fontSize);
    }

    public String getChatBackground() {
        return mChatBackground;
    }

    public void setChatBackground(String chatBackground) {
        mChatBackground = chatBackground;
        System.out.println("将数据库中聊天背景设置为" + chatBackground);
    }
}
